<template>
    <div class="common-layout">
        <el-container>
            <el-header style="position: relative;left:1100px ;">
                <div class="dg">
                    {{ dg.name }}
                    <el-avatar :src="dg.pic" />
                </div>
                <el-dropdown placement="bottom">
                    <el-button> bottom </el-button>
                    <template #dropdown>
                        <el-dropdown-menu>
                            <el-dropdown-item>The Action 1st</el-dropdown-item>
                            <el-dropdown-item>The Action 2st</el-dropdown-item>
                            <el-dropdown-item> <el-button plain @click="open">退出</el-button></el-dropdown-item>
                        </el-dropdown-menu>
                    </template>
                </el-dropdown>

            </el-header>
            <el-container>
                <el-aside width="200px"> <el-row class="tac">
                        <el-col :span="24">
                            <h5 class="mb-2">Default colors</h5>
                            <el-menu default-active="2" class="el-menu-vertical-demo" @open="handleOpen"
                                @close="handleClose" router>
                                <el-sub-menu index="1">
                                    <template #title>
                                        <el-icon>
                                            <location />
                                        </el-icon>
                                        <span>Navigator One</span>
                                    </template>
                                    <el-menu-item index="/home">item two</el-menu-item>
                                </el-sub-menu>
                                <el-sub-menu index="2">
                                    <template #title>
                                        <el-icon>
                                            <location />
                                        </el-icon>
                                        <span>列表页</span>
                                    </template>
                                    <el-menu-item index="/home/xr">查询表单</el-menu-item>
                                    <el-menu-item index="/home/crad">卡片列表</el-menu-item>
                                </el-sub-menu>
                                    <el-sub-menu index="3">
                                    <template #title>
                                        <el-icon>
                                            <location />
                                        </el-icon>
                                        <span>Navigator One</span>
                                    </template>
                                    <el-menu-item index="/home/404">item two</el-menu-item>
                                </el-sub-menu>
                                    <el-sub-menu index="4">
                                    <template #title>
                                        <el-icon>
                                            <location />
                                        </el-icon>
                                        <span>Navigator One</span>
                                    </template>
                                    <el-menu-item index="/home">item two</el-menu-item>
                                </el-sub-menu>
                                    <el-sub-menu index="5">
                                    <template #title>
                                        <el-icon>
                                            <location />
                                        </el-icon>
                                        <span>Navigator One</span>
                                    </template>
                                    <el-menu-item index="/home">item two</el-menu-item>
                                </el-sub-menu>
                                    <el-sub-menu index="6">
                                    <template #title>
                                        <el-icon>
                                            <location />
                                        </el-icon>
                                        <span>Navigator One</span>
                                    </template>
                                    <el-menu-item index="/home">item two</el-menu-item>
                                </el-sub-menu>
                                    <el-sub-menu index="7">
                                    <template #title>
                                        <el-icon>
                                            <location />
                                        </el-icon>
                                        <span>个人中心 </span>
                                    </template>
                                    <el-menu-item index="/home/yhxx">用户信息</el-menu-item>
                                    <el-menu-item index="/home/yhsz">用户设置</el-menu-item>
                                </el-sub-menu>
                            </el-menu>
                        </el-col>

                    </el-row></el-aside>
                <el-main>
                    <router-view></router-view>
                </el-main>
            </el-container>
        </el-container>
    </div>
</template>

<script setup>
import { getUserInfoApi } from '@/api/api'
import { ref } from 'vue'
const dg = ref([])
getUserInfoApi().then(res => {
    console.log(res);
    dg.value = res.data.data
})
import { ElMessage, ElMessageBox } from 'element-plus'
import { useRouter } from 'vue-router'
const router = useRouter()
const open = () => {
    ElMessageBox.confirm(
        'proxy will permanently delete the file. Continue?',
        'Warning',
        {
            confirmButtonText: 'OK',
            cancelButtonText: 'Cancel',
            type: 'warning',
        }
    )
        .then(() => {
            ElMessage({
                type: 'success',
                message: 'Delete completed',
            })
            localStorage.clear()
            router.push('/login')
        })
        .catch(() => {
            ElMessage({
                type: 'info',
                message: 'Delete canceled',
            })
        })
}
</script>

<style lang="scss" scoped></style>